<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="阿福易购">
    <meta content="telephone=no" name="format-detection" />
    <meta content="email=no" name="format-detection" />
    <!-- uc、qq浏览器 -->
    <meta name="screen-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="browsermode" content="application">
    <meta name="x5-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="x5-page-mode" content="app">
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <meta name="csrf-token" class="notAll" content="{{ csrf_token() }}" />
    <title>确认订单_{{$SEO['title']}}</title>
    <link rel="stylesheet" href="{{ asset('/build/css/app.min.css') }}">
</head>
<body ontouchstart="" class="no-goTop">

@inject('cartService','App\Interfaces\CartService')

@inject('pictureService','App\Interfaces\PictureService')

@inject('discountService','App\Interfaces\DiscountService')
<div id="orderSection">
<header class="ui-header ui-header-stable af-header">
    <ul class="ui-row-flex">
        <li class="ui-col ui-flex ui-flex-pack-start">
            <i ontouchstart="window.history.back();" class="ui-icon-return af-icon-home"></i>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-center">
            <h1>确认订单</h1>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-end">

        </li>
    </ul>
</header>

<footer class="ui-footer af-footer ui-goods-footer">
    <button class="J-submitBtn ui-btn-lg ui-btn-danger">
        提交订单
    </button>
</footer>

<div class="ui-container"  >
<form action="">
    <section class="ui-my-toolbar af-border-tb af-step">
        @if( !$address->isEmpty() )
            @foreach($address as $key=>$value)
                @if($value['is_default'])
                     <h2 class="J-orderAddress tool-item">
                         <span><i class="ui-icon-personal ui-tool-icon" style="color: red;margin-top: -18px;width: 20px;"></i><span class="J-remove af-hide" style="margin-left: 4px">添加收货地址</span></span>
                         <span class="J-showT"><span class="J-name">{{$value['consignee']}}</span><span class="af-step-phone" style="float: right;"><i></i><span class="J-phone ">{{$value['mobile']}}</span></span></span>
                         <p class="J-showT J-address ui-txt-info" style="padding-top: 5px;">
                         @if(!in_array(trim($value['province']), $cities))
                                {{$value['province']}}
                            @endif
                            {{ $value['city'].$value['district'].$value['address'] }}
                         </p>
                         <input class="J-showT" id="address_id" type="hidden" name="address_id" value="{{$value['address_id']}}">
                     </h2>

                    <b class="af-step-borderT"></b>
                    <b class="af-step-borderB"></b>
                @endif
            @endforeach
        @else
        <h2 class="J-orderAddress tool-item">
            <span><i class="ui-icon-personal ui-tool-icon" style="color: red;margin-top: -18px;width: 20px;"></i><span class="J-remove" style="margin-left: 4px">添加收货地址</span></span>
            <span class="J-showT af-hide"><span class="J-name"></span><span class="af-step-phone" style="float: right;"><i></i><span class="J-phone "></span></span></span>
            <p class="J-showT J-address ui-txt-info af-hide" style="padding-top: 5px;"></p>
            <input class="J-showT" id="address_id" type="hidden" name="address_id" value="">
        </h2>

        <b class="af-step-borderT"></b>
        <b class="af-step-borderB"></b>
        @endif
    </section>

    @if($info['orders']['cshopGoods'])
    <div class="ui-my-order af-border-tb">
        <div class="ui-my-order-header">
            <div class="title">
                免税商品
            </div>
        </div>
        <div class="ui-my-order-content">
            <ul class="ui-list  af-border-tb">
                @foreach($info['orders']['cshopGoods']['orderGoods'] as $key=>$goods)
                <li class="ui-border-t" onclick="window.location.href='goods/show/{{$goods['goods_id']}}'" >
                    <div class="ui-list-img">
                        <span style="background-image:url({{$pictureService::thumb($goods['goods_thumb'], 70, 70)}})"></span>
                    </div>
                    <div class="ui-list-info">
                        <h4 class="ui-nowrap">{{ $goods['goods_name'] }}</h4>
                        <h4>×{{ $info['buyGoods'][$goods['goods_id']] }}</h4>

                    </div>
                </li>
                <input type="hidden" name="goods[{{$key}}][goods_id]" value="{{$goods['goods_id']}}">
                <input type="hidden" name="goods[{{$key}}][buy_num]" value="{{$info['buyGoods'][$goods['goods_id']]}}">
                @endforeach
            </ul>
        </div>
    </div>
    @endif

    @if($info['orders']['eshopGoods'])
    <div class="ui-my-order af-border-tb">
        <div class="ui-my-order-header">
            <div class="title">
                E贸易商品
            </div>
        </div>
        <div class="ui-my-order-content">
            <ul class="ui-list  af-border-tb">
                @foreach($info['orders']['eshopGoods']['orderGoods'] as $key=>$goods)
                <li class="ui-border-t" onclick="window.location.href='goods/show/{{$goods['goods_id']}}'">
                    <div class="ui-list-img">
                        <span style="background-image:url({{$pictureService::thumb($goods['goods_thumb'], 70, 70)}})"></span>
                    </div>
                    <div class="ui-list-info">
                        <h4 class="ui-nowrap">{{ $goods['goods_name'] }}</h4>
                        <h4>×{{ $info['buyGoods'][$goods['goods_id']] }}</h4>

                    </div>
                </li>
                <input type="hidden" name="goods[{{$key}}][goods_id]" value="{{$goods['goods_id']}}">
                <input type="hidden" name="goods[{{$key}}][buy_num]" value="{{$info['buyGoods'][$goods['goods_id']]}}">
                @endforeach
            </ul>
        </div>

    </div>
    @endif

    <section class="ui-my-toolbar af-border-tb ui-order-coupon-list">
        <h2 class="tool-item"><span>优惠券(限用一张)</span></h2>

        @if (count($info['orders']['eshopGoods']['coupons'])>0 || count($info['orders']['cshopGoods']['coupons'])>0)
            
                @if(count($info['orders']['eshopGoods']['coupons'])>0)
                <?php $user_coupons = $info['orders']['eshopGoods']['coupons']; ?>
                <ul class="J-couponList ui-list ui-list-text ui-list-radio ui-border-tb" data-type="e_coupon_id">

                    @foreach($user_coupons as $available_key=>$available_value)
                        <li class="ui-border-t">
                            <label class="ui-radio">
                                <input type="radio" name="e_coupon_id" value="{{$available_value['id']}}" >
                                满{{$available_value['limit_fir']}}减{{$available_value['value']}}元
                            </label>
                        </li>
                    @endforeach
                    </ul>
                @endif

                @if(count($info['orders']['cshopGoods']['coupons'])>0)
                <?php $user_coupons = $info['orders']['cshopGoods']['coupons'];?>
                <ul class="J-couponList ui-list ui-list-text ui-list-radio ui-border-tb" data-type="c_coupon_id">

                    @foreach($user_coupons as $available_key=>$available_value)
                        <li class="ui-border-t">
                            <label class="ui-radio">
                                <input type="radio" name="c_coupon_id" value="{{$available_value['id']}}" >
                                满{{$available_value['limit_fir']}}减{{$available_value['value']}}元
                            </label>
                        </li>
                    @endforeach
                    </ul>
                @endif
            
        @else
            <h2><span class="ui-txt-muted">无可用优惠券</span></h2>
        @endif

        <!-- <ul class="J-couponList ui-list ui-list-text ui-list-radio ui-border-tb" data-type="e_coupon_id">
            <li class="ui-border-t">
                <label class="ui-radio">
                    <input type="radio" name="coupon" value="1" checked>
                    满100减50
                </label>
            </li>
            <li class="ui-border-t">
                <label class="ui-radio">
                    <input type="radio" name="coupon" value="2">
                    满200减120
                </label>
            </li>
        </ul> -->
    </section>

    <section class="ui-my-toolbar af-border-tb  ">
        <h2 class="tool-item af-border-b "><span>  支付方式</span><span style="float: right">在线支付</span></h2>
        <ul class="J-payType ui-list ui-pay-type-list">
            @if (strpos($_SERVER["HTTP_USER_AGENT"], 'AppleWebKit'))
                @if (strpos($_SERVER["HTTP_USER_AGENT"], 'MicroMessenger'))
                    <li class="af-border-t" data-type="weixin">
                        <div class="ui-avatar">
                            <span style="background-image:url(/build/images/weixin.jpg)"></span>
                        </div>
                        <div class="ui-list-info">
                            <h4 class="ui-nowrap">微信支付</h4>
                            <p class="ui-nowrap">推荐已安装微信的用户使用</p>
                        </div>
                        <label class="ui-checkbox-s ui-check-pay-type">
                            <input type="checkbox" name="payType" value="3">
                        </label>
                    </li>
                @else
                    <li data-type="alipay">
                        <div class="ui-avatar">
                            <span style="background-image:url(/build/images/biao.png)"></span>
                        </div>
                        <div class="ui-list-info">
                            <h4 class="ui-nowrap">支付宝</h4>
                            <p class="ui-nowrap">推荐支付宝用户使用</p>
                        </div>
                        <label class="ui-checkbox-s ui-check-pay-type">
                            <input type="checkbox" name="payType" value="1" checked>
                        </label>
                    </li>
                @endif
            @else

                非移动端不能支付！
            @endif
            <!-- <li class="af-border-t" data-type="pingan">
                <div class="ui-avatar">
                    <span style="background-image:url(/build/images/pingan.jpg)"></span>
                </div>
                <div class="ui-list-info">
                    <h4 class="ui-nowrap">平安支付</h4>
                    <p class="ui-nowrap">使用您的平安账号进行支付</p>
                </div>
                <label class="ui-checkbox-s ui-check-pay-type">
                    <input type="checkbox" name="payType" value="3">
                </label>
            </li> -->
        </ul>
    </section>

    <section class="ui-my-toolbar af-border-tb  ">
        <h2 class="tool-item"><span>  配送信息</span><span style="float: right">快递配送</span></h2>
    </section>

    <section class="ui-my-toolbar ui-border-tb" style="padding-bottom: 40px;">
        <h2 class="tool-item "><span>  金额合计</span><span class="J-price order_price" style="float: right">¥{{number_format($info['total_order_price'],2,'.','')}}</span></h2>
        <h2 class="tool-item"><span>  关税</span><span class="J-price tariff_fee" style="float: right">¥{{number_format($info['total_tariff_fee'],2,'.','')}}</span></h2>
        <h2 class="tool-item "><span>  运费</span><span class="J-price shipping_fee" style="float: right">¥{{number_format($info['total_shipping_fee'],2)}}</span></h2>
        <h2 class="tool-item "><span>  优惠券</span><span style="float: right">-<span class="J-price coupon_price">¥0.00</span></span></h2>
        <h2 class="tool-item "><span>  限时折扣</span><span style="float: right">-¥{{number_format($info['total_discount_price'],2)}}</span></h2>
        <h2 class="tool-item ui-border-t "><span style="float: right">实付款: <span class="J-price pay_price">¥{{number_format($info['total_pay_price'],2,'.','')}}</span></span></h2>
    </section>
</form>
</div>
</div>


<!--地址弹出框-->
<section id="addressCover" class="ui-cover-wrap" data-id="1234">
    <ul class="ui-cover-scroll ui-cover-ths">
        <li class="J-mask ui-cover-mask"></li>
        <li class="J-listWrap ui-cover" data-id="123">
            <div class="ui-header ui-header-stable af-header">
                <ul class="ui-row-flex">
                    <li class="ui-col ui-flex ui-flex-pack-start">
                        <i class="ui-icon-return"></i>
                    </li>
                    <li class="ui-col ui-flex ui-flex-pack-center">
                        <h1>收货地址</h1>
                    </li>
                    <li class="ui-col ui-flex ui-flex-pack-end">
                    </li>
                </ul>
            </div>

            <div class="ui-footer af-footer">
                <div class="ui-btn-wrap" style="margin-top: -10px;">
                    <button class="J-add ui-btn-lg ui-btn-danger">
                        新建收货地址
                    </button>
                </div>
            </div>
            <div class="ui-container" style="overflow-y: scroll;">

                <ul class="J-list ui-address-card">
                @if( !$address->isEmpty() )
                    @foreach($address as $key=>$value)
                            <li class="ui-border-tb" data-id="{{$value['address_id']}}">
                                <h3>
                                    <span class="J-item name" data-name="consignee" data-val="{{$value['consignee']}}">{{$value['consignee']}}</span>
                                    <span class="J-item phone" data-name="mobile" data-val="{{$value['mobile']}}">{{$value['mobile']}}</span>
                                </h3>
                                <div class="address">
                                    <span class="J-item @if(!in_array(trim($value['province']), $cities)) af-hide @endif" data-name="province" data-val="{{$value['province']}}">{{$value['province']}}</span>
                                    <span class="J-item" data-name="city" data-val="{{$value['city']}}">{{$value['city']}}</span>
                                    <span class="J-item" data-name="district" data-val="{{$value['district']}}">{{$value['district']}}</span>
                                    <span class="J-item" data-name="address" data-val="{{$value['address']}}">{{$value['address']}}</span>
                                    <span class="J-item af-hide" data-name="country" data-val="中国"></span>
                                    <span class="J-item af-hide" data-name="position_ids" data-val="{{$value['position_ids']}}"></span>
                                    <span class="J-item af-hide" data-name="id_card" data-val="{{$value['id_card']}}"></span>
                                    <span class="J-item af-hide" data-name="is_default" data-val="{{$value['is_default']}}"></span>
                                </div>
                                <div class=" tool  ui-border-t">
                                    <span class="select">
                                       <label class="ui-radio">
                                           <input type="radio" @if($value['is_default']) checked @endif name="radio">
                                           选择
                                       </label>
                                    </span>
                                    <span class="op ui-tiled">
                                        <label class="J-edit"><i class="ui-icon-order"></i>编辑</label>
                                        <label class="J-del"><i class="ui-icon-delete"></i>删除</label>
                                    </span>
                                </div>
                            </li>
                    @endforeach
                @endif

                </ul>

            </div>
        </li>
        <li class="J-formWrap ui-cover">
            <div class="ui-header ui-header-stable af-header">
                <ul class="ui-row-flex">
                    <li class="ui-col ui-flex ui-flex-pack-start">
                        <i class="ui-icon-return"></i>
                    </li>
                    <li class="ui-col ui-flex ui-flex-pack-center">
                        <h1>收货地址</h1>
                    </li>
                    <li class="ui-col ui-flex ui-flex-pack-end">
                    </li>
                </ul>
            </div>
            <div class="ui-footer af-footer">
                <div class="ui-btn-wrap" style="margin-top: -10px;">
                    <button class="J-submit ui-btn-lg ui-btn-danger" >
                        确定
                    </button>
                </div>
            </div>
            <div class="ui-container">
                <div class="ui-form">
                    <form class="J-form" action="#">
                        <div class="ui-form-item ui-border-b">
                            <label for="areaInput">
                                所在地区
                            </label>
                            <input id="areaInput" type="text" placeholder="请选择所在地区" required readonly/>
                            <input id="areaIds" type="hidden" name="position_ids" value=""/>
                            <input type="hidden" name="country" value="中国"/>
                            <input type="hidden" name="province" value=""/>
                            <input type="hidden" name="city" value=""/>
                            <input type="hidden" name="district" value=""/>
                        </div>
                        <div class="ui-form-item ui-form-item-textarea ui-border-b">
                            <label for="address">
                                详细地址
                            </label>
                            <textarea id="address" name="address" placeholder="无需重复填写省市区，小于75个字" data-reg-msg="请输入详细地址" maxlength="75" required></textarea>
                        </div>
                        <div class="ui-form-item ui-border-b">
                            <label for="consignee">
                                收货人姓名
                            </label>
                            <input id="consignee" type="text" name="consignee" placeholder="请输入收货人姓名" required>
                            <a href="#" class="ui-icon-close af-hide"></a>
                        </div>
                        <div class="ui-form-item ui-border-b">
                            <label for="id_card">
                                身份证号码
                            </label>
                            <input id="id_card" type="text" name="id_card" placeholder="请输入身份证号码" data-reg="(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$)" required data-reg-msg="请输入正确的身份证号码">
                            <a href="#" class="ui-icon-close af-hide"></a>
                        </div>
                        <div class="ui-form-item ui-border-b">
                            <label for="mobile">
                                手机号码
                            </label>
                            <input id="mobile" type="text" name="mobile" placeholder="请输入手机号码" data-reg="^1[3|4|5|7|8]\d{9}$" required data-reg-msg="请输入正确的手机号码">
                            <a href="#" class="ui-icon-close af-hide"></a>
                        </div>
                        <div class="ui-form-item ui-form-item-switch ui-border-b">
                            <p>
                                设为默认地址
                            </p>
                            <label class="ui-switch">
                                <input type="checkbox" name="is_default" value="1">
                            </label>
                        </div>
                    </form>
                </div>
            </div>

        </li>
    </ul>
</section>

<script id="addressTpl" type="text/html">
    <li class="ui-border-tb" data-id="${id}">
        <h3>
            <span class="J-item name" data-name="consignee" data-val="${consignee}">${consignee}</span>
            <span class="J-item phone" data-name="mobile" data-val="${mobile}">${mobile}</span>
        </h3>
        <div class="address">
            <span class="J-item" data-name="province" data-val="${province}">${province}</span>
            <span class="J-item" data-name="city" data-val="${city}">${city}</span>
            <span class="J-item" data-name="district" data-val="${district}">${district}</span>
            <span class="J-item" data-name="address" data-val="${address}">${address}</span>
            <span class="J-item af-hide" data-name="country" data-val="中国"></span>
            <span class="J-item af-hide" data-name="position_ids" data-val="${position_ids}"></span>
            <span class="J-item af-hide" data-name="id_card" data-val="${id_card}"></span>
            <span class="J-item af-hide" data-name="is_default" data-val="${is_default}"></span>
        </div>
        <div class=" tool  ui-border-t">
            <span class="select">
               <label class="ui-radio">
                   <input type="radio" name="radio">
                   选择
               </label>
            </span>
            <span class="op ui-tiled">
                <label class="J-edit"><i class="ui-icon-order"></i>编辑</label>
                <label class="J-del"><i class="ui-icon-delete"></i>删除</label>
            </span>
        </div>
    </li>
</script>
<!--省市区联动-->
<link rel="stylesheet" href="{{ asset('/build/js/LArea/LArea.min.css') }}">
<script src="{{ asset('/build/js/LArea/LAreaData1.js') }}"></script>
<script src="{{ asset('/build/js/LArea/LArea.min.js') }}"></script>

<script src="{{ asset('/build/lib/zepto.min.js') }}"></script>
<script src="{{ asset('/build/js/frozen.js') }}"></script>
<script src="{{ asset('/build/js/app.min.js') }}"></script>
<script>
    $(function () {
        var config={
            ajaxInfo:'/order',//获取订单价格
            makeOrder:'/order',//创建订单
            orderDetail:'/my/order',//去订单详情页
            alipay:'/pay/request',//支付宝支付路径
            weixin:'/pay/request',//微信支付
            pingan:'/pay/request',//平安支付
            addUrl:'/my/address/create',//添加地址
            editUrl:'/my/address',//修改地址
            delUrl:'/my/address'//删除地址
        };
        new MakeOrder(config);
    });
</script>
</body>
</html>